﻿namespace MyFloridaHouse.libSvOpenDistricts.Districts
{
    public partial class DistrictPlan
    {


        //public bool SaveIsolatedCanExecute(enumFileSaveFileSource fileSaveFileSource)
        //{
        //    if (districtCount > 0)
        //    {
        //        if (fileSaveFileSource == enumFileSaveFileSource.LOCAL)
        //        {
        //            return false;
        //        }
        //        else
        //        {
        //            if (districtPlanFileName != null)
        //            {
        //                if (districtPlanFileName.Length > 0)
        //                {
        //                    return true;
        //                }
        //            }
        //        }
        //    }
        //    return false;
        //}

        //public void SaveIsolated() //going to isolated storage
        //{
        //    int maxDistricts = 0;
        //    string districtPlanTypeID = "";
        //    if (ExtractPlanType(districtPlanFileName, out districtPlanTypeID, out maxDistricts))
        //    {
        //        byte[] fileDataWithFormatCodeSerialized = SerializeFormatAndData();
        //        byte[] fileDataWithFormatCodeSerializedAndCompressed = CompressionManager.Compress(fileDataWithFormatCodeSerialized);
        //        IsolatedStorageIncreaseDialog isolatedStorageIncreaseDialog = new IsolatedStorageIncreaseDialog();
        //        isolatedStorageIncreaseDialog.SaveToIsolatedStorageWithDialog(Constants.DistrictPlanDirectoryName, districtPlanFileName + Constants.DistrictPlanFileNameExtension, fileDataWithFormatCodeSerializedAndCompressed);
        //    }
        //}


        //private byte[] SerializeFormatAndData()
        //{
        //    // serialize data
        //    DistrictPlanSaveFormat saveDistrict = new DistrictPlanSaveFormat(this, this.districtCount);
        //    byte[] fileDataSerialized = SerializationManager.Serialize(saveDistrict);
        //    return fileDataSerialized;
        //}

        //private bool LoadInternalFormatPlan(byte[] fileData)
        //{
        //    byte[] fileDataSerializedAndCompressed = fileData;
        //    byte[] fileDataSerialized = CompressionManager.DecompressToByteArray(fileDataSerializedAndCompressed);
        //    DistrictPlanSaveFormat districtPlanToLoad = (DistrictPlanSaveFormat)SerializationManager.Deserialize(typeof(DistrictPlanSaveFormat), fileDataSerialized);
        //    districtPlanTypeName = DistrictPlanTypes.districtPlanTypesInstance.GetDistrictPlanTypeNameFromID(districtPlanToLoad.districtPlanTypeID);
        //    districtPlanFileName = districtPlanToLoad.districtPlanFileName;
        //    InitializeDistrictPlan(districtPlanToLoad.condensedList.Count - 1, districtPlanToLoad.districtPlanTypeID, districtPlanTypeName);
        //    for (int districtID = 0; districtID < districtPlanToLoad.condensedList.Count; districtID++)
        //    {
        //        string districtUogIDList = districtPlanToLoad.condensedList[districtID];
        //        if (districtUogIDList.Length > 0)
        //        {
        //            List<int> uogIDList = new List<int>();
        //            foreach (var uogID in districtUogIDList.Split(','))
        //            {
        //                if (uogID.Length > 0)
        //                {
        //                    uogIDList.Add(Convert.ToInt32(uogID));
        //                }
        //            }
        //            SetUogListToDistrict(districtID, uogIDList);
        //        }
        //    }
        //    return true;
        //}
    }
}
